package com.itheima.quest_test.controller;
import com.itheima.quest_test.method.DbConn;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.itheima.quest_test.table.table;

import java.sql.SQLException;

@RestController
public class java_mysql {

    //增加
    @RequestMapping("/insertData")
    public String insertData(table item) throws SQLException {
        System.out.println(item);
       DbConn.InsertData(item.getItemname(), item.getValue());
        return "ok";
    }

    //修改
    @RequestMapping("/upData")
    public String upData(table item) throws SQLException {
        System.out.println(item);
        DbConn.updateData(item.getId(), item.getValue());
        return "ok";
    }

    //删除
    @RequestMapping("/deleteData")
    public String deleteData(table item) throws SQLException {
        System.out.println(item);
        DbConn.deleteData(item.getId());
        return "ok";
    }

    //查询
    @RequestMapping("/selectData")
    public String selectData(table item) throws SQLException {
        System.out.println(item);
        DbConn.selectData();
        return "ok";
    }
}


